package ms.maplestory.boot.service;

import lombok.RequiredArgsConstructor;
import ms.maplestory.boot.client.character.CharStat;
import ms.maplestory.boot.client.character.ExtendSP;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashSet;
import java.util.Set;

@Service
@RequiredArgsConstructor
public class ExtendSPService extends JpaService<ExtendSP, Integer> {

    @Transactional
    public Set<ExtendSP> createExtendSP(int subJobs, CharStat charStat) {
        Set<ExtendSP> extendSPS = new HashSet<>();
        for (int i = 1; i <= subJobs; i++) {
            ExtendSP extendSP = new ExtendSP();
            extendSP.setJobLevel((byte) i);
            extendSP.setSp(0);
            extendSP.setCharStat(charStat);
            extendSPS.add(extendSP);
        }
        saveAll(extendSPS);
        return extendSPS;
    }
}
